#include "draw.h"

#include "libtcod.hpp"

int rel_x, rel_y;

void draw(Theme::Theme theme, Level* level, Hero* hero, 
		std::vector<Person*> people)
{
	char c;
	TCODColor color;

	// clear screen
	if(theme == Theme::BW_White)
	{
		TCODConsole::root->setBackgroundColor(TCODColor::white);
		TCODConsole::root->setForegroundColor(TCODColor::black);
	}
	else
	{
		TCODConsole::root->setBackgroundColor(TCODColor::black);
		TCODConsole::root->setForegroundColor(TCODColor::white);
	}
	TCODConsole::root->clear();

	// draw level
	for(int x=0; x < level->w; ++x)
		for(int y=0; y < level->h; ++y)
		{
			if(theme == Theme::Color)
				TCODConsole::root->setFore(x, y, level->tiles[x][y]->color);
			TCODConsole::root->setChar(x, y, level->tiles[x][y]->c);
		}

	// draw hero
	c = hero->Char(&color);
	if(theme == Theme::Color)
		TCODConsole::root->setFore(hero->x, hero->y, color);
	TCODConsole::root->setChar(hero->x, hero->y, c);

	// flush
	TCODConsole::root->flush();
}
